import time
from date_util import DateUtil


class CarInfo:
    """ 车类，包括 车牌 开始停放时间 结束停放时间 """

    def __init__(self, plate_number, start_time, end_time, price):
        super(CarInfo, self).__init__()
        self.plate_number = plate_number
        """ 车牌号 """
        self.start_time = start_time
        """ 开始停放时间 """
        self.end_time = end_time
        """ 车主姓名 """
        self.price = price
        """ 支付的停车费 """

    @staticmethod
    def query_info(start_time, unit_price):
        """ 封装查询信息打印 """
        d2 = DateUtil.get_current_date_str()
        t1 = DateUtil.str2timestamp(start_time)
        t2 = time.time()
        times = t2 - t1
        price = (times / 3600) * unit_price
        print("您停了%.2f小时，应付款%d￥" % (times / 3600, price))
        return d2, price

    def get_plate_number(self):
        return self.plate_number

    def get_start_time(self):
        return self.start_time

    def get_end_time(self):
        return self.end_time

    def get_price(self):
        return self.price
